segunda-feira, 25 de novembro de 2024

How to show errors in JSON string, RegEx string in Microsoft Visual Studio

Example:

//lang=regex
var pattern = "(Mr\\.???\\? |Mrs\\.? |Miss |Ms\\.? )";

//lang=json,strict
var json = """
            {

                "name": "TONY",
                "age": 36,
                "books":
                    [
                        {"Title": "ABC"},
                        {"Title": "DEF"}
                    ]
            }
           """;


Sources:

JSON002: Probable JSON string detected - Visual Studio (Windows) | Microsoft Learn

Hassan Habib on X: "Did you know that Microsoft Visual Studio will show you errors in your JSON string if you just put a comment //lang=json? #json #csharp #dotnet https://t.co/Ir7HR9Cbw1" / X

See also:

.NET regular expressions
https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions

ReGex Generator
https://regex-generator.olafneumann.org/

regex101: build, test, and debug regex
https://regex101.com/


sábado, 23 de novembro de 2024

My git rebase annotations: Using another editor, nano, for rebasing

⚠️Be careful using any of those commands. Only use them if you know what you are doing.

These steps and commands are here for my reference.

Git reset

If just want to clear a series of commits without losing the work that was done on files:

git reset --mixed [Commit-Id]

The commits after CommitId will be removed on your local branch and the files that were on these commits will return to stage area, so now you can create a new commit wich includes the files:

git commit -m "Write your commit message here"

And then send this new history to the server and replace the older one with:

git push --force 

sexta-feira, 22 de novembro de 2024

Request variables in HTTP files

 HTTP files now support request variables. That is where you can send a request and then use data from the response, or request, in future requests.


When working with HTTP files, a common scenario is calling an endpoint, taking a value from the response, and sending in a subsequent request. For example, you may call an endpoint to authenticate a user and then on later calls you can pass the token that was returned from the login endpoint. Prior to this release this was not possible in Visual Studio. In the snippet below you can see an example of how this works in an HTTP file.


# @name login

POST {{TodoApi_HostAddress}}/users/token

Content-Type: application/json


{

  "username": "{{myusername}}",

  "password": "{{mypassword}}"

}


###


GET {{TodoApi_HostAddress}}/todos

Authorization: Bearer {{login.response.body.$.token}}


###



domingo, 10 de novembro de 2024

How to configure Microsoft Authenticator on mobile phone using the QR code on a computer

 On the computer, go to:

https://mysignins.microsoft.com/security-info



Click on 
Add sign-in method

Microsoft Authenticator

It will generate a QR code

ON the mobile app, select + Add account
corporative or student

Read a QR Code

Then point the mobile camera to the computer QR code.

...

terça-feira, 5 de novembro de 2024

How to open CSV file in Excel with , (comma) separator

 

It is possible to add:

sep=,

at the beginning of the file, and Excel will display the columns.
Example:

sep=,
"LETTER","ANIMAL"
"a","aardvark"
"b","bear"
"c","cow"

Source: https://superuser.com/q/773644/274615